package net.libra.animatedBitmap
{
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.geom.Point;
	import flash.geom.Rectangle;

	/**
	 * 
	 * @author elvisjiang
	 * 
	 */	
	public class SliceBitmapTool
	{
		public function SliceBitmapTool()
		{
		}
		/**
		 * 横切
		 * @param width 单个bitmap的width
		 * @param num 数量
		 * @param source 数据源
		 * @return bitmapdataArray 
		 * 
		 */			
		public  static function sliceBitmap(width:Number,height:Number,num:int,source:BitmapData):Vector.<BitmapData>
		{
			var bitmapdataArray:Vector.<BitmapData> = new Vector.<BitmapData>;
			var rect:Rectangle;
			var point:Point = new Point(0,0);
			
			for(var i:int = 0;i<num;i++)
			{
				var bitmapdata:BitmapData = new BitmapData(width,height,true,0);
				rect = new Rectangle(i*width,0,width,height);
				bitmapdata.copyPixels(source,rect,point);
				bitmapdataArray.push(bitmapdata);
			}
			return bitmapdataArray;
		}
	}
}